/*******************************************************************************
 * Copyright (c) 2010, 2030 www.itlaobing.cn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package cn.itlaobing.shopping.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import cn.itlaobing.shopping.model.UserModel;

/** 
 * ClassName: UserDao <br/> 
 * Function: 用户数据访问类 <br/> 
 * date: 2017年11月1日 上午10:24:24 <br/> 
 * 
 * @author 王建蕊 
 * @version 1.0 
 * @since JDK 1.8 
 */
public class UserDao {
	private DBHelper dh=new DBHelper();
	/** 
	 * close:(关闭). <br/>
	 * 
	 * @author Administrator 
	 * @throws SQLException 
	 * @since JDK 1.8 
	 */  
	public void close() throws SQLException{
		dh.close();
	}
	/** 
	 * login:(用户登录). <br/>
	 * 
	 * @author Administrator 
	 * @param username
	 * @param userpwd
	 * @return
	 * @throws ClassNotFoundException
	 * @throws SQLException 
	 * @since JDK 1.8 
	 */  
	public UserModel login(String username,String userpwd)throws ClassNotFoundException,SQLException {
		String sql="select * from users where username=? and userpwd=?";
		ResultSet rs=dh.executeQuery(sql, username,userpwd);
		UserModel um=null;
		if(rs.next()) {
			um=new UserModel();
			um.setId(rs.getInt(1));
			um.setUsername(rs.getString("username"));
			um.setUserpwd(rs.getString("userpwd"));
			um.setLasttime(rs.getString("lasttime"));
			um.setNickname(rs.getString("nickname"));
			um.setTelephone(rs.getString("telephone"));
		}
		return um;
	}
	public void updateLasttime(int id)throws sqle{

	}
}
